package books.borrowing.services;

import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;

import org.springframework.beans.factory.annotation.Autowired;

import books.borrowing.dao.impl.BookBorrowingDao;
import books.borrowing.entity.BookBorrowingEntity;

@WebService(serviceName="BookBorrowingService")
@SOAPBinding(style = Style.RPC, use = Use.LITERAL)
public class BookBorrowingService {

	@Autowired
	BookBorrowingDao rentDao;

	public void setBookBorrowingDao(BookBorrowingDao _rentDao) {
		this.rentDao = _rentDao;
	}

	@WebMethod
	public void save(BookBorrowingEntity _rent) throws Exception {
		this.rentDao.save(_rent);
	}

	@WebMethod
	public void update(BookBorrowingEntity _rent) {
		this.rentDao.update(_rent);
	}

	@WebMethod
	public void delete(BookBorrowingEntity _rent) {
		this.rentDao.delete(_rent);
	}

	@WebMethod
	public BookBorrowingEntity rentBook(String _login, String _ISBN)
			throws Exception {
		return this.rentDao.rentBook(_login, _ISBN);
	}

	@WebMethod
	public BookBorrowingEntity returnBook(String _login, String _ISBN) {
		return this.rentDao.returnBook(_login, _ISBN);
	}

	@WebMethod
	public List<BookBorrowingEntity> findRent(String _login, String _ISBN) {
		return this.rentDao.findRent(_login, _ISBN);
	}
	
	@WebMethod
	public List<BookBorrowingEntity> findSubscriberRents(String _login) {
		return this.rentDao.findSubscriberRents(_login);
	}
}
